<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of axpx</title>
  <meta name="keywords" content="axpx">
  <meta name="description" content="[y]=AXPX(A,X)">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="#">tt2</a> &gt; <a href="index.html">misc</a> &gt; axpx.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for tt2/misc&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>axpx
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>[y]=AXPX(A,X)</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [y]=axpx(a,x) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">[y]=AXPX(A,X)
This is a technical function that multiplies
Matrix A by a vector and projects on X itself; 
This is for time-stepping</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="../../tt2/@tt_matrix/conj.html" class="code" title="function [b]=conj(a)">conj</a>	Complex conjugate of a TT-matrix</li><li><a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>	Mode sizes of the TT-matrix</li><li><a href="../../tt2/@tt_tensor/conj.html" class="code" title="function [tt1]=conj(tt)">conj</a>	Compute a complex conjugate of TT-tensor</li><li><a href="../../tt2/@tt_tensor/qr.html" class="code" title="function [tt,rm]=qr(tt,op)">qr</a>	Left and right orthogonalization of the TT-format</li><li><a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>	Reshape of the TT-tensor</li><li><a href="../../tt2/@tt_tensor/size.html" class="code" title="function [sz] = size(tt,dim)">size</a>	Mode sizes of the TT-tensor</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [y]=axpx(a,x)</a>
0002 <span class="comment">%[y]=AXPX(A,X)</span>
0003 <span class="comment">%This is a technical function that multiplies</span>
0004 <span class="comment">%Matrix A by a vector and projects on X itself;</span>
0005 <span class="comment">%This is for time-stepping</span>
0006 
0007 d=x.d;
0008 n=a.n;
0009 m=a.m;
0010 rx=x.r;
0011 psx=x.ps;
0012 att=a.tt;
0013 corea=att.core;
0014 psa=att.ps;
0015 ra=att.r;
0016 <span class="comment">%Do right-to-left orthogonalization and computation of psi</span>
0017 <span class="comment">%matrices</span>
0018 corex=x.core;
0019 pos1=psx(d+1);
0020 psi=cell(d+1,1); <span class="comment">%Psi-matrices</span>
0021 psi{d+1}=1; psi{1}=1;
0022 cr1=corex(psx(d):psx(d+1)-1);
0023 y=x;
0024 corey=y.core;
0025 psy=y.ps;
0026 ry=y.r;
0027 <span class="keyword">for</span> i=d:-1:2 
0028    <span class="comment">%  fprintf('i=%d \n');</span>
0029    cr2=corey(psy(i-1):psy(i)-1);
0030    cr1=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cr1,[ry(i),n(i)*ry(i+1)]);
0031    cr2=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cr2,[ry(i-1)*n(i-1),ry(i)]);
0032    cr1=cr1.';
0033    [q,rm]=<a href="../../tt2/@tt_tensor/qr.html" class="code" title="function [tt,rm]=qr(tt,op)">qr</a>(cr1,0); rn=<a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(q,2); rm=rm.';
0034    q=q.'; 
0035    ry(i)=rn;
0036    corey(pos1-ry(i+1)*n(i)*ry(i):pos1-1)=q(:);
0037       <span class="comment">%Convolution is now performed for psi(i) using psi(i+1) and corea, and</span>
0038    <span class="comment">%(new) core q</span>
0039    cra=corea(psa(i):psa(i+1)-1); cra=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cra,[ra(i),n(i),m(i),ra(i+1)]);
0040    cry=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(<a href="../../tt2/@tt_matrix/conj.html" class="code" title="function [b]=conj(a)">conj</a>(q),[ry(i),n(i),ry(i+1)]);
0041    crx=corex(psx(i):psx(i+1)-1);
0042    crx=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(crx,[rx(i),m(i),rx(i+1)]);
0043    pscur=psi{i+1}; pscur=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(pscur,[ra(i+1),rx(i+1),ry(i+1)]); <span class="comment">%ra,rx,ry</span>
0044    <span class="comment">%First, convolve over rx(i+1)</span>
0045    crx=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(crx,[rx(i)*m(i),rx(i+1)]);
0046     pscur=permute(pscur,[2,1,3]); pscur=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(pscur,[rx(i+1),ra(i+1)*ry(i+1)]);
0047    pscur=crx*pscur; <span class="comment">%pscur is now rx(i)*m(i)*ra(i+1)*ry(i+1)</span>
0048    <span class="comment">%Convolve over m(i),ra(i+1),n(i),ry(i+1)</span>
0049     pscur=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(pscur,[rx(i),m(i)*ra(i+1),ry(i+1)]);
0050     pscur=permute(pscur,[1,3,2]); 
0051     pscur=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(pscur,[rx(i)*ry(i+1),m(i)*ra(i+1)]);
0052     cra=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cra,[ra(i)*n(i),m(i)*ra(i+1)]); cra=cra.';  
0053     pscur=pscur*cra; 
0054     <span class="comment">%pscur is now rx(i)*ry(i+1)*ra(i)*n(i), it is left to convolve over</span>
0055     <span class="comment">%n(i)*ry(i+1)</span>
0056     pscur=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(pscur,[rx(i),ry(i+1),ra(i),n(i)]);
0057     pscur=permute(pscur,[3,1,4,2]);
0058     pscur=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(pscur,[ra(i)*rx(i),n(i)*ry(i+1)]);
0059     cry=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cry,[ry(i),n(i)*ry(i+1)]); cry=cry.';
0060     pscur=pscur*cry; <span class="comment">%pscur is ra*rx*ry</span>
0061     pscur=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(pscur,[rx(i),ra(i),ry(i)]);
0062     psi{i}=pscur;
0063    <span class="comment">%End of psi-block</span>
0064    pos1=pos1-ry(i+1)*n(i)*ry(i);
0065    cr1=cr2*rm;
0066 <span class="keyword">end</span>
0067 corey(pos1-ry(2)*n(1)*ry(1):pos1-1)=cr1(:);
0068 pos1=pos1-ry(2)*n(1)*ry(1);
0069 corey=corey(pos1:end); <span class="comment">%Truncate unused elements</span>
0070 <span class="comment">%Now compute the projection itself while recomputing psi-matrices</span>
0071  pos1=1;
0072  psy=cumsum([1;n.*ry(1:d).*ry(2:d+1)]);
0073  rm=1;
0074  <span class="comment">%keyboard;</span>
0075   <span class="keyword">for</span> i=1:d
0076           <span class="comment">%Our convolution is</span>
0077      <span class="comment">%ps1(ra(i),rx(i),ry(i))*cra(ra(i),n(i),m(i),ra(i+1))</span>
0078      <span class="comment">%*ps2(ra(i+1),rx(i+1),ry(i+1))*crx(rx(i),m(i)*rx(i+1))-&gt;</span>
0079      <span class="comment">%cry(ry(i),n(i),ry(i+1)</span>
0080 
0081      ps1=psi{i}; ps2=psi{i+1};
0082      cra=corea(psa(i):psa(i+1)-1);
0083      crx=corex(psx(i):psx(i+1)-1);
0084 <span class="comment">%     corey(psy(i):psy(i+1)-1)=crx(:);</span>
0085 <span class="comment">%     y.core=corey;</span>
0086 <span class="comment">%          psy=cumsum([1;n.*ry(1:d).*ry(2:d+1)]);</span>
0087 <span class="comment">%     y.ps=psy;</span>
0088      ps1=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(ps1,[ra(i),rx(i),ry(i)]);
0089      ps1=permute(ps1,[2,3,1]);
0090      ps1=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(ps1,[rx(i)*ry(i),ra(i)]);
0091      cra=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cra,[ra(i),n(i)*m(i)*ra(i+1)]);
0092      cry=ps1*cra;      <span class="comment">%cry is rx(i)*ry(i)*n(i)*m(i)*ra(i+1)</span>
0093      <span class="comment">%convolve over m(i),rx(i) with crx</span>
0094      cry=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cry,[rx(i),ry(i),n(i),m(i),ra(i+1)]);
0095      cry=permute(cry,[2,3,5,1,4]);
0096      cry=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cry,[ry(i)*n(i)*ra(i+1),rx(i)*m(i)]);
0097      crx=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(crx,[rx(i)*m(i),rx(i+1)]);
0098      cry=cry*crx; cry0=cry;
0099      <span class="comment">%cry is ry(i)*n(i)*ra(i+1)*rx(i+1)</span>
0100      cry=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cry,[ry(i)*n(i),ra(i+1)*rx(i+1)]);
0101      ps2=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(ps2,[ra(i+1)*rx(i+1),ry(i+1)]);
0102      <span class="comment">%cry0=cry; %cry0 is ry(i)*n(i)*ra(i+1)*rx(i+1), convolution over ry(i)*n(i) will bring new psi --- not true; new psi will be brought with and</span>
0103      <span class="comment">%orthogonalization</span>
0104      cry=cry*ps2;
0105       corey(pos1:pos1+ry(i)*n(i)*ry(i+1)-1)=cry(:);
0106       y.core=corey;
0107       psy=cumsum([1;n.*ry(1:d).*ry(2:d+1)]);
0108       y.ps=psy;
0109        <span class="comment">%keyboard;</span>
0110     
0111      cry=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cry,[ry(i)*n(i),ry(i+1)]);
0112      [q,rm]=<a href="../../tt2/@tt_tensor/qr.html" class="code" title="function [tt,rm]=qr(tt,op)">qr</a>(cry,0);
0113      rn=<a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(q,2);
0114      ry(i+1)=rn;
0115      <span class="comment">%q=q*rm;</span>
0116      corey(pos1:pos1+ry(i)*n(i)*ry(i+1)-1)=q(:);
0117      pos1=pos1+ry(i)*n(i)*ry(i+1);
0118      <span class="comment">%And now --- orthogonalization! (of cry) (he-he)</span>
0119      <span class="comment">%Now compute &quot;new&quot; psi</span>
0120      <span class="comment">%We need to compute</span>
0121           <span class="comment">%cry is rx(i)*ry(i)*n(i)*m(i)*ra(i+1)</span>
0122      <span class="comment">%convolve over m(i),rx(i) with crx</span>
0123      <span class="comment">%cry0 is ry(i)*n(i)*ra(i+1)*rx(i+1);</span>
0124      cry0=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cry0,[ry(i),n(i),ra(i+1),rx(i+1)]);
0125      cry0=permute(cry0,[3,4,1,2]);
0126      cry0=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cry0,[ra(i+1)*rx(i+1),ry(i)*n(i)]);
0127      q=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(<a href="../../tt2/@tt_matrix/conj.html" class="code" title="function [b]=conj(a)">conj</a>(q),[ry(i)*n(i),ry(i+1)]);
0128      psi{i+1}=cry0*q;
0129      
0130   <span class="keyword">end</span>
0131   psy=cumsum([1;n.*ry(1:d).*ry(2:d+1)]);
0132   corey(psy(i):psy(i+1)-1)=corey(psy(i):psy(i+1)-1)*rm;
0133   y.core=corey;
0134   y.r=ry;
0135   y.ps=psy;
0136   y.n=n;
0137   y.d=d;
0138   <span class="keyword">return</span>
0139 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Wed 08-Feb-2012 18:20:24 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>